<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/includes.jsp" %>
<c:choose>
	<c:when test="${enterprise.new}"><c:set var="method" value="post"/></c:when>
	<c:otherwise><c:set var="method" value="put"/></c:otherwise>
</c:choose>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>浙江孵化器在线后台管理系统</title>
    <link href="<spring:url value="/static/style/index.css" htmlEscape="true" />" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="<spring:url value="/static/js/jquery-1.4.3.js" htmlEscape="true" />"></script>
    <%@include file="/WEB-INF/jsp/inc/calendar.jsp"%>
</head>
<body>
<div class="list_right_title">
    <span><img src="<spring:url value="/static/images/im.jpg" htmlEscape="true" />" alt="信息管理"></span>光伏在线>>光伏企业>>添加
</div>
<div class="fhq_add">
    <div class="fhq_add_in">
        <div class="fhq_add_form">
            <form:form modelAttribute="enterprise" method="${method}" action="/management/enterprises" enctype="multipart/form-data">
            <form:hidden path="id"/>
            <table class="fhq_add_table" cellpadding="0" cellspacing="" summary="光伏在线>>光伏企业>>添加">
                <tr>
                    <th width="20%">名称：</th>
                    <td width="80%">
                        <form:input path="title" cssClass="add_form_input"/>
                    <form:errors path="title" cssClass="error" />
                    </td>
                </tr>
                <tr>
                    <th>归类：</th>
                    <td>
                        <form:checkboxes items="${allCategories}" path="categoryBits" onclick="onChangeCategory(this)"/>
                    </td>
                </tr>
                <c:forEach var="category" items="${allCategories}">
                    <tr id="category_${category.key}" style="display:none">
                        <th>${category.value}：</th>
                        <td>
                            <c:if test="${not empty allCategoryProducts[category.key]}">
                                <form:checkboxes items="${allCategoryProducts[category.key]}" path="productList" itemLabel="name"  itemValue="id" delimiter="&nbsp;&nbsp;"/>
                            </c:if>
                            <input type="hidden" name="productListIds" value="-1"/>
                        </td>
                    </tr>
                </c:forEach>
                <script type="text/javascript">
                    function onChangeCategory(checkbox) {
                        var trContainer = document.getElementById("category_"+checkbox.value);
                        if (checkbox.checked) {
                            trContainer.style.display = "";
                        } else {
                            trContainer.style.display = "none";
                        }
                        for (var j = 1; ; j++) {
                            var product = document.getElementById("productList"+j);
                            if (!product) break;
                            if (product.parentNode.parentNode.parentNode.style.display=="none") {
                                product.name="";
                            } else {
                                product.name="productListIds";
                            }
                        }
                    }
                    function initProducts() {
                        var theForm = document.getElementById("enterprise");
                        var categoryBits = theForm["categoryBits"];
                        for (var i = 0; i < categoryBits.length; i ++) {
                            if (categoryBits[i].checked) {
                                document.getElementById("category_"+categoryBits[i].value).style.display="";
                            } else {
                                document.getElementById("category_"+categoryBits[i].value).style.display="none";
                            }
                        }
                        for (var j = 1; ; j++) {
                            var product = document.getElementById("productList"+j);
                            if (!product) break;
                            if (product.parentNode.parentNode.parentNode.style.display=="none") {
                                product.name="";
                            } else {
                                product.name="productListIds";
                            }
                        }
                    }
                    function checkProduct(value) {
                        for (var j = 1; ; j++) {
                            var product = document.getElementById("productList"+j);
                            if (!product) break;
                            if (product.value==value) {
                                product.checked=true;
                            } else {
                                product.checked=false;
                            }
                        }
                    }
                    initProducts();

                </script>
                <tr>
                    <th>LOGO：</th>
                    <td>
                        <c:if test="${enterprise.haveLogo}">
                            <img src="<spring:url value="/static/upload/enterprise/${enterprise.id}/logo.jpg?r=${random}" htmlEscape="true" />" alt="logo">
                        </c:if>
                        <br/>
                        <input name="logoFile" type="file">
                    </td>
                </tr>
                <tr>
                    <th>推荐：</th>
                    <td>
                        <form:radiobuttons items="${allRecommendOptions}" path="recommend"/>
                    </td>
                </tr>
                <tr>
                    <th>是否会员：</th>
                    <td>
                        <form:radiobuttons items="${allIsMemberOptions}" path="member"/>
                    </td>
                </tr>
                <tr>
                    <th>会员码：</th>
                    <td>
                        <form:input path="memberCode"/>
                    </td>
                </tr>
                <tr>
                    <th>企业网址：</th>
                    <td>
                        http://<form:input path="homeUrl" class="add_form_input"/>

                    </td>
                </tr>
                <tr>
                    <th>联系电话：</th>
                    <td>
                        <form:input path="phone" class="add_form_input"/>
                    </td>
                </tr>
                <tr>
                    <th>企业邮箱：</th>
                    <td>
                        <form:input path="email" class="add_form_input"/>
                    </td>
                </tr>
                <tr>
                    <th>企业联系人：</th>
                    <td>
                        <form:input path="linkman" class="add_form_input"/>
                    </td>
                </tr>
                <tr>
                    <th>企业联系人电话：</th>
                    <td>
                        <form:input path="linkmanPhone" class="add_form_input"/>
                    </td>
                </tr>
                <tr>
                    <th>企业联系人邮箱：</th>
                    <td>
                        <form:input path="linkmanEmail" class="add_form_input"/>
                    </td>
                </tr>
                <tr>
                    <th>摘要：</th>
                    <td>
                        <form:textarea path="summary" rows="3" cols="135"/>
                    </td>
                </tr>
                <tr>
                    <th>简介：</th>
                    <td>
                        <FCK:editor instanceName="EditorDefault" inputName="content" height="500"  value="${enterprise.content}">
                        </FCK:editor>
                    </td>
                </tr>
                <tr>
                    <th>权值：</th>
                    <td>
                        <form:input path="orderCode" cssClass="add_form_input"/>
                    </td>
                </tr>
                <tr>
                    <th>发布时间：</th>
                    <td>
                        <form:input path="publishDate" cssClass="add_form_input"/> 发布状态：
                        <form:select path="publishStatus" items="${allPublishStatus}" cssClass="fhq_add_select"/>
                    </td>
                </tr>
                <tr>
                    <th>&nbsp;</th>
                    <td style="padding-top:20px;">
                        <!--<input type="button" value=" 保存并报送 ">　　　-->
                        <input type="submit" value=" 保存 "/>　　　<input type="button" value=" 返回 " onclick="window.location.href='search'"/>
                    </td>
                </tr>
            </table>
            </form:form>
        </div>
    </div>
</div>
</body>
</html>